package com.rattsoftware.client.controllers;

import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.google.gwt.core.client.GWT;
import com.rattsoftware.client.AppMessages;
import com.rattsoftware.client.webclient;
import com.rattsoftware.client.events.AppEvents;
import com.rattsoftware.client.service.FacultyServiceAsync;
import com.rattsoftware.client.service.UserServiceAsync;
import com.rattsoftware.client.views.NewEditFacultyView;

public class NewEditFacultyController extends Controller {
	
    AppMessages appMessages = GWT.create(AppMessages.class);
    private UserServiceAsync userService;
    private FacultyServiceAsync facultyService;
    
    private NewEditFacultyView newEditFacultyView;

    public NewEditFacultyController() {
        super();
        userService = Registry.get(webclient.USER_SERVICE);
        facultyService = Registry.get(webclient.FACULTY_SERVICE);
        registerEventTypes(AppEvents.NewFaculty);
        registerEventTypes(AppEvents.EditFaculty);
    }
    
    @Override
    protected void initialize() {
    	GWT.log("NewEditFacultyController : initialize");
		super.initialize();
		newEditFacultyView = new NewEditFacultyView(this);
    }

    @Override
	public void handleEvent(AppEvent event) {
		GWT.log("NewEditFacultyController : handleEvent");
		EventType type = (EventType) event.getType();
		if (type == AppEvents.NewFaculty) {
			forwardToView(newEditFacultyView, event);
		} else if (type == AppEvents.EditFaculty) {
			forwardToView(newEditFacultyView, event);
		}
	}
}